<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Login</title>
    <script src="jquery.min.js"></script>
    <script src="jsencrypt.min.js"></script>

    
    
    
    
<script type="text/javascript">

function jsEncode(){
	var encrypt = new JSEncrypt();
	var pubk = $("#public_key").val();
    encrypt.setPublicKey(pubk);
    var text = $("#text").val();
	
    var data = encrypt.encrypt(text);
	
	$("#encode_text").val(data);
}   

function jsDecode(){
	var decrypt  = new JSEncrypt();
	var pubk = $("#private_key").val();
    decrypt.setPrivateKey(pubk);
    var encodeText = $("#encode_text").val();
	
    var data = decrypt.decrypt(encodeText);
	
	alert(data);
} 
</script>
</head>
<body>
    <div>

        
        私钥:<textarea  rows="5" id="private_key"  cols="65">MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAIK2l62kOOFJQJaKonU2nyG3lrIHSfcp4Yu1wLgQsGYiKBxKM+1Xp93KSTIM2c359491nP20HvmPD8MGOJHSu/4HWEW+h8R2SKS+JO+9UBb+ZKGyojf28Fnb4L2VkpvXuFazKk5iCeGSid2SRKwqLZXPS8YZpxIT2gMnP5dyhzXPAgMBAAECgYBHA5ZSIxc35gkuAHGUhrFbqxc271jS7DD6KythlMeRJVtvSyz89BNiHqU3iN3H1tcVXIuHFhWB9aRViwquxrOU1OIxagkkCXGd+qZuaeENjqvBbr/uooCf2ZaQdFxb44VG5cXk5uTcBC5ZNQWNeEhaXxD6r+aCBA4My7UUiLTHmQJBAP0zUcbbTvW1sDKAZR+fTkw+fC9kxqDHHLpdSd+/SB3pv/83klF5c4Bwo9PSF59YZFG04SiLDXEhFGgWneUbRa0CQQCEKJMaJU7aDlyEpq8CcNGOU4AU20KvSVbxBWk0ybKmKad76SrFSzSM5rECTvx3wHW4fp2NnOC/DO85FshJv0DrAkAp4E37HJRfkPAWOiP/aeKSO5dgY0NyndvDeuBX8BPmVp2ZgUBi1zpiGL8PrmSXxw+4b7j5cp4DgtwUJwFwPeV1AkASMoQO1ZRF8jRLD6iJbX9tWZIJTSeheze9eEFEQ4GV36ZwKWr6P6C8xgcZika5Nob/IHART8iiheVqtvhdLziBAkARTH7aaEEOyynDFObpcj+z2Z7jmxUd/d0eOd/kIMJCYoK7zrosf/Wrt3/c+tvxFL/K3AJUXvYTtworqKCEnofF</textarea>
        <hr/>
       公钥:<textarea rows="5" id="public_key"  cols="65">MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCCtpetpDjhSUCWiqJ1Np8ht5ayB0n3KeGLtcC4ELBmIigcSjPtV6fdykkyDNnN+fePdZz9tB75jw/DBjiR0rv+B1hFvofEdkikviTvvVAW/mShsqI39vBZ2+C9lZKb17hWsypOYgnhkondkkSsKi2Vz0vGGacSE9oDJz+Xcoc1zwIDAQAB</textarea>
        <hr/>
   明文: <input type="text" id="text" value="woshi中国@.com">
   <hr/>
      <input type="button" onclick="jsEncode()" value="前端加密" />
      <hr/>
   密文:  <textarea type="text" id="encode_text" rows="5" cols="65" ></textarea>
   <hr/>
     <input type="button" onclick="jsDecode()" value="后端解密" /> 
   <hr/>

    </div>
</body>
</html>